package com.suven.framework.generator.temp;

import com.suven.framework.generator.config.ProjectPathConfig;

import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
/**
 * @author 作者 : suven
 * @version 版本: v1.0.0
 *
 * <pre>
 * @ description (说明):
 * </pre>
 * <pre>
 * 修改记录
 *    修改后版本:     修改人：  修改日期:     修改内容:
 * </pre>
 * @ date 创建时间: 2024-01-08
 **/
public enum ProjectNameEnum {

    //ddd saas 服务代码项目模块规划枚举 http-app, http-web, http-facade, http-vo, api-service, api-client, rpc-dto,rpc_infrastructure,//
    //http service项目 adapter
    SAAS_HTTP_FACADE(1,1,"http-%s-service","saas","业务接口实现"),
    //后台管理系统
    SAAS_HTTP_CONTROLLER_WEB(2,2,"http-admin-service","saas","后台管理系统"),

    //app service + domain //提供内部mvc使用
    SAAS_APP_SERVICE(3,3,"app-%s-service","saas","app-service-domain //提供内部mvc使用"),

    //后台sys api
    SAAS_HTTP_VO_PARAMETER(4,4,"api-%s-vo","saas","AddRequestVo和ResponseVo"),
    //微服务,提供外部服务调用 api service项目 app + domain 提供外部spring cloud使用,通过代码实现对外服务
    SAAS_API_SERVICE(5,5,"api-%s-service","saas","Api.java"),


    //domain 基础公共对象配置,各业务组合对象实现类,包括网络组合
    SAAS_RPC_DTO_DOMAIN(6,6,"domain-%s-service","saas","RequestDto 请求参数,数据条件查询枚举"),
    //rpc infrastructure 数据读取领域(包括数据库,redis数据读取,以及第三方依懒库或包)
    SAAS_RPC_INFRASTRUCTURE(7,7,"rpc-%s-infrastructure","saas","infrastructure领域驱动项目"),
    //获取第三方网络SDK_client请求
    SAAS_RPC_SDK_CLIENT(8,8,"rpc-%s-sdk-client","saas","infrastructure领域驱动项目"),


    // rpc 服务代码项目模块规划枚举 http, api, rpc 执行流程:http-facade-rpc-service-dao-mapping-xml //
    //MYBATIS 后台sys api
    //domain 基础公共对象配置,各业务组合对象实现类,包括网络组合
    MYBATIS_RPC_SERVICE(1,1,"rpc-%s-service","mybatis","RPC_SERVICE 服务"),
    //微服务,提供外部服务调用 api service项目 app + domain 提供外部spring cloud使用,通过代码实现对外服务
    MYBATIS_API_SERVICE(2,2,"api-%s-service","mybatis","Api接口和参数服务"),
    MYBATIS_HTTP_SERVICE(3,3,"http-%s-service","mybatis","应用接口服务"),
    MYBATIS_SYS_SERVICE(4,4,"sys-%s-service","mybatis","后台管理服务"),

    ;



    private static Map<String, Map<Integer,ProjectNameEnum>> typeMap = new HashMap<>();
    static {

        for(ProjectNameEnum type : values()) {
            Map<Integer,ProjectNameEnum> map = typeMap.get(type.projectType);
            if (Objects.isNull(map)){
                map = new HashMap<>();
                typeMap.put(type.projectType, map);
            }
            map.put(type.tempCode,type);

        }
    }


    public static ProjectNameEnum  getEnum(String projectType,int tempCode) {
        Map<Integer,ProjectNameEnum> map =  typeMap.get(projectType);
        if (Objects.isNull(map)){
            return null;
        }
        return map.get(tempCode);
    }

    //saas实现
    public static String  getProjectName(String projectType,int tempCode,String modules) {
        Map<Integer,ProjectNameEnum> map =  typeMap.get(projectType);
        if (Objects.isNull(map)){
            return null;
        }
        ProjectNameEnum projectNameEnum =  map.get(tempCode);
        if (Objects.isNull(projectNameEnum)){
            return null;
        }
        String projectNane = projectNameEnum.getProjectName();
        if (Objects.isNull(projectNane)){
            return null;
        }
        return String.format(projectNane, modules);
    }
    //界面实现
    public static String getProjectPath(int createCodeEnumIndex, ProjectPathConfig projectPathConfig){
        return projectPathConfig.getProjectPath(createCodeEnumIndex);
    }
    public String getProjectName() {
        return projectName;
    }

    public String getProjectType() {
        return projectType;
    }

    private int index;
    private int tempCode;
    private String projectName;
    private String projectType;
    private String projectInfo;

    ProjectNameEnum(int index,int tempCode,String projectName, String projectType, String projectInfo){
        this.index = index;
        this.tempCode = tempCode;
        this.projectName = projectName;
        this.projectType = projectType;
        this.projectInfo = projectInfo;
    }
}
